package jmind.asteroidea.core.reducer;

/**
 * description: 取结果最大值
 * @author weibo.xie
 * @date:2022/7/11 下午2:36
 */
public class MaxOfReducer extends Reducer<Number> {



    @Override
    public boolean isBreak(String tag, Number result) {
        return false;
    }

    @Override
    public Number reduce() {
        return getResult().values().stream().max((n1, n2) -> {
            double diff = n1.doubleValue() - n2.doubleValue();
            return diff > 0 ? 1 : (diff < 0 ? -1 : 0);
        }).orElse(null);

    }

}
